package com.yootk.test;

import java.net.URL;
import java.util.Scanner;

/**
 * Java原生访问WEB程序
 */
public class AccessEchoServer {

    public static void main(String[] args) throws Exception {
        String requestUrl = "http://localhost/echo.action?msg=www.yootk.com";
        URL url = new URL(requestUrl); // 要发出GET请求
        // 当进行请求的发送之后，肯定需要有HTML的响应内容，所以需要打开输入流接收全部的数据
        Scanner scanner = new Scanner(url.openStream());
        scanner.useDelimiter("\n");
        while(scanner.hasNext()) {
            System.out.println(scanner.next());
        }
        scanner.close();
    }
}
